//
//  CommonTool.h
//  cocoapodText
//
//  Created by apple on 16/9/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#ifndef CommonTool_h
#define CommonTool_h


#endif /* CommonTool_h */
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface CommonTool : NSObject
/**
 *Toast提示
 */
+ (void)showAllTextDialogWithText:(NSString *)text parentView:(UIView *)view;
+ (void)showAllTextDialogInTopWithText:(NSString *)text parentView:(UIView *)view;
+ (void)showAllTextDialogInBottomWithText:(NSString *)text parentView:(UIView *)view;
/**
 *standardUserDefaults存储
 */
+(Boolean)isHaveValue:(NSString *)key;
+(NSString *)getValueFromKey:(NSString *)key defaultValue:(NSString *)value;
+(void)updateValueWithKey:(NSString *)key value:(NSString *)key_value;
/**
 *字典中取字符串
 */
+(NSString *)getStringFromNSDictionary:(NSDictionary *)obj key:(NSString *)key defaultValue:(NSString *)value;
/**
 * 数组中取字符串
 */
+(NSString *)getStringFromNSArray:(NSArray *)obj key:(int)key;
/**
 *nsinteger转int
 */
+(int)NSIntegerToInt:(NSInteger )integer;

/**
 *@name 字符串转日期
 *@param dateStr 时间字符串
 *@param rule format规则
 */
+(NSDate *)StringToDate:(NSString *)dateStr rule:(NSString *)rule;

/**
 *@name 获取当前时间
 *@param dateStr 时间字符串
 *@param rule format规则
 */
+(NSString *)getNowDateWithRule:(NSString *)rule;


/**
 *@name 获取当前时间
 *@param dateStr 时间字符串
 *@param rule format规则
 */
+(NSString *)getNowDateTime;

/**
 *@name 时间戳转时间
 *@param timestamp 时间戳字符串
 *@param rule format规则
 */
+(NSString *)getNowDateTimeByTimestamp:(NSString *)timestamp Rule:(NSString *)rule;

/**
 *@name 获取年月日与现在时间的年月日做差的日期
 *@param year 年差
 *@param month 月差
 *@param day 日差
 *@param rule format规则
 */
+(NSString *)getDateTimeDifferenceWithYear:(int)year Month:(int)month Day:(int)day Rule:(NSString *)rule;
/**
 *@name 获取年月日与指定时间的年月日做差的日期
 *@param year 年差
 *@param month 月差
 *@param day 日差
 *@param rule format规则
 *@param date 指定日期
 */
+(NSString *)getDateTimeDifferenceWithYear:(int)year Month:(int)month Day:(int)day Rule:(NSString *)rule Date:(NSDate *)date;

/**
 *@name 两个数相除获取大于等于结果的整数
 *@param divisor  除数
 *@param dividend 被除数
 */
+(int)getGreaterThanOrEqualToNumWithDivisor:(int)divisor Dividend:(int)dividend;


/**
 *@name 判断是否登陆过期
 *
 */
+(bool)isLoginExpired;
/**
 *@name 保留两位小数
 */
+(NSString *)keepDecimal:(NSString *)str;

//判断是否为整形：
+(BOOL)isPureInt:(NSString*)string;
//判断是否为浮点形：
+(BOOL)isPureFloat:(NSString*)string;
//判断是否是纯数字
+(BOOL)isPureNum:(NSString *)string;

/**
 *@name 判断session是否过期
 *
 */
+(void)isSessionExpired:(NSURLSessionDataTask *)task;
/**
 *@name 添加小数点
 */
+(NSString *)addXiaoShuDian:(NSString *)num;
//UIColor 转UIImage
+(UIImage*) createImageWithColor: (UIColor*) color Frame:(CGRect)frame;
//UIImage转UIColor
+(UIColor *)createColorWhiteImage:(NSString *)image;
@end
